<template>
	<view>
		<view  v-if="isLoading == true"><image class="loading" src="https://huajia-online-1316192331.cos.ap-guangzhou.myqcloud.com/static/loading-1.gif"></image></view>
		<view v-if="isLoading == false">
			<!-- <view><image mode="widthFix" class="image" src=""></image></view> -->
			<image class="background" src="https://huajia-online-1316192331.cos.ap-guangzhou.myqcloud.com/static/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20221201185147.png"></image>
			<!-- <image class="background" src="https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500"></image> -->
			<view class="enrollContent" @click="enrollContent">报名详情</view>
			<view class="message">
				<view class="title">{{ title }}</view>
				<view>
					<image class="icon" src="https://huajia-online-1316192331.cos.ap-guangzhou.myqcloud.com/static/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202023-04-06%20220954.png">
						<view class="char">报名截止时间 {{ deadline }}</view>
					</image>
					<!-- <image class="icon" src="../../static/屏幕截图 2023-04-06 220954.png">
						<view class="char">报名截止时间 {{ deadline }}</view>
					</image> -->
				</view>
				<view>
					<image class="icon1" src="https://huajia-online-1316192331.cos.ap-guangzhou.myqcloud.com/static/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202023-04-06%20220954.png">
						<view class="char1">活动时间 {{ beginActivityTime }}~{{endActivityTime}}</view>
					</image>
					<!-- <image class="icon1" src="../../static/屏幕截图 2023-04-06 220954.png">
						<view class="char1">活动时间 {{ beginActivityTime }}~{{ endActivityTime }}</view>
					</image> -->
				</view>
				<view>
					<image class="icon2" src="https://huajia-online-1316192331.cos.ap-guangzhou.myqcloud.com/static/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202023-04-06%20211027.png">
						<view class="char2">{{ tel }}</view>
					</image>
					<!-- <image class="icon2" src="../../static/屏幕截图 2023-04-06 211027.png">
						<view class="char2">{{ tel }}</view>
					</image> -->
				</view>
				<view>
					<image class="icon3" src="https://huajia-online-1316192331.cos.ap-guangzhou.myqcloud.com/static/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202023-04-06%20205809.png">
						<view class="char3">{{ address }}</view>
					</image>
					<!-- <image class="icon3" src="../../static/屏幕截图 2023-04-06 205809.png">
						<view class="char3">{{ address }}</view>
					</image> -->
				</view>
				<view>
					<image class="icon4" src="https://huajia-online-1316192331.cos.ap-guangzhou.myqcloud.com/static/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202023-04-06%20221216.png">
						<view class="char4">{{ activeNum }}</view>
					</image>
					<!-- <image class="icon4" src="../../static/屏幕截图 2023-04-06 221216.png">
						<view class="char4">{{ activeNum }}</view>
					</image> -->
				</view>
				<view>
					<image class="icon5" src="https://huajia-online-1316192331.cos.ap-guangzhou.myqcloud.com/static/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202023-04-06%20205738.png">
						<view class="char5">{{ applicants }}</view>
					</image>
					<!-- <image class="icon5" src="../../static/屏幕截图 2023-04-06 205738.png">
						<view class="char5">{{ applicants }}</view>
					</image> -->
				</view>
				<view class="introduction">活动简介:</view>
				<view>{{ activeContent }}</view>
				<view class="order">报名要求:</view>
				<view>{{ orderContent }}</view>
				<button class="enroll" @click="showDialog" v-if="lea > 0 && isEnroll == 0">我要报名</button>
				<button class="checkIn" v-if="checkIn == 1" @click="checkedIn">签到</button>
			</view>
		</view>
		
	</view>
</template>

<script>
export default {
	data() {
		return {
			title: '无',
			id: null,
			readFlag: null,
			refId: null,
			sendTime: '',
			msg: '',
			deadline: '2023-4-25',
			beginActivityTime: '2023-4-26',
			endActivityTime: '2023-5-10',
			tel: '无',
			address: '无',
			activeNum: '无',
			applicants: '0',
			activeContent: '无',
			orderContent: '无',
			show: false,
			message: '这是一段内容',
			lea:'',
			isEnroll:1,
			checkIn:0,
			isLoading:true
		};
	},
	onShow: function() {
		// let that = this;
		// uni.setNavigationBarTitle({
		// 	title:'系统通知'
		// });
		// that.ajax(that.url.searchMessageById, "POST", {"id":that.id}, function(resp){
		// 	let result = resp.data.result;
		// 	that.sendTime = result.sendTime;
		// 	that.msg = result.msg;
		// })
	},
	onLoad: function(options) {
		let that = this;
		that.id = options.id;
		that.readFlag = options.readFlag == 'true' ? true : false;
		that.refId = options.refId;
		that.isEnroll = options.isEnroll;
		that.checkIn = options.checkIn;
		that.ajax(that.url.searchActivityContentById, 'POST', { id: options.id }, function(resp) {
			that.title = resp.data.result[0].title;
			that.deadline = resp.data.result[0].endEnroll_time;
			that.beginActivityTime = resp.data.result[0].begin_time;
			that.endActivityTime = resp.data.result[0].end_time;
			that.tel = resp.data.result[0].tel;
			that.address = resp.data.result[0].place;
			that.activeNum = resp.data.result[0].number;
			that.applicants = resp.data.result[0].applicant_num;
			that.activeContent = resp.data.result[0].content;
			that.orderContent = resp.data.result[0].ord;
			that.lea = resp.data.result[0].lea;
		});
		setTimeout(function(resp) {
			that.isLoading = false
		}, 400);
	},
	methods: {
		checkedIn(){
			let that = this;
			that.ajax(that.url.checkIn, "POST", {id:that.id}, function(resp){
				uni.showToast({
					icon:'none',
					title:'签到成功！'
				})
			})
		},
		enrollContent(){
			uni.navigateTo({
				url:'/pages/enrollContent/enrollContent'
			})
		},
		showDialog() {
			let that = this;
			uni.showModal({
				title: '提示信息',
				content: '是否要确认报名？（报名后无法取消，如有疑问请查看报名详情）',
				success: function(resp) {
					if (resp.confirm) {
						that.ajax(that.url.updateActivityEnrollment, 'POST', { id: that.id }, function(resp) {
							if (resp.data.result == '报名成功！') {
								uni.showToast({
									title: '报名成功！'
								});
								setTimeout(function(resp){
									uni.switchTab({
										url:'/pages/index/index'
									})
								}, 1000)
							}
						});
					}
				}
			});
		},
		// enroll() {
		// 	let that = this;
		// 	that.ajax(that.url.updateActivityEnrollment, 'POST', { id: that.id }, function(resp) {
		// 		if (resp.data.result == '报名成功！') {
		// 			uni.showToast({
		// 				title: '报名成功！'
		// 			});
		// 		}
		// 	});
		// },
	}
};
</script>

<style lang="less">
@import url('message.less');
</style>
